package summary;

import java.math.BigInteger;
import java.util.Arrays;

/**
 * @Author: 海琳琦
 * @Date: 2022/4/6 17:44
 */
public class Sword14_II {

    public static int cuttingRope(int n) {
        final int r = 1000000000 + 7;
        BigInteger[] dp = new BigInteger[n + 1];
        Arrays.fill(dp, BigInteger.valueOf(1));
        for (int i = 3; i <= n; i++) {
            for (int j = 1; j <= i - 1; j++) {
                dp[i] = dp[i].max(BigInteger.valueOf(j * (i - j))).max(dp[i - j].multiply(BigInteger.valueOf(j)));
            }
        }
        return dp[n].mod(BigInteger.valueOf(r)).intValue();
    }

    public static int cuttingRope1(int n) {
        if (n < 4) {
            return n - 1;
        }
        long result = 1;
        while (n >= 4) {
            result = result * 3 % 1000000007;
            n -= 3;
        }
        return (int) (result * n) % 1000000007;
    }

    public static void main(String[] args) {
        int i = cuttingRope(10);
        System.out.println(1);
    }
}
